<?php 
class Zend_Template_Navigation{

    private $_menus;  //inclue actions

    public function __construct($menus){
        $this->_menus = $menus;
    }

    public function render(){       
        $str = "";
        //get menu 
        foreach($this->_menus as $menu){
            if(!empty($menu->controller_name)){
                $template = $this->readTemplate();
                $menu->parent = "";
                foreach($menu as $key => $val){
                    if(is_string($val) || empty($val)){
                        $template = str_replace('{'.$key.'}', empty($val) ? '' : $val, $template);
                    }
                }
                $str .= $template;
            }
        }
        
        return $str;
    }

    public function readTemplate(){
        $template = file_get_contents(PATH_STRUCTURE.'/zend-framework/templates/navigation.tpl');
        return $template; 
    }

    public function writeFile(){
        $template = $this->render();

        $path = PATH_PROJECT_GENERAL.'/'.
        NAME_PROJECT_GENERAL.'/application/layouts/navigation.ini';

        $hand = fopen($path, 'w');
        fwrite($hand, $this->render($template));
        fclose($hand);    
    }


}